﻿using Entity.Finance.DTO.DailyReimburse;
using Entity.Finance.View.DailyReimburse;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Service;
using Service.Finance;
using Service.System;

namespace AnQinManagermentBackendAPI.Controller.Finance
{
    /// <summary>
    /// 报销单
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    [Authorize]
    [AllowAnonymous]
    public class DailyReimbursesController : ControllerBase
    {
        /**
         * 业务接口
         */
        private readonly DailyReimburseService _service;

        /**
         * 构造函数注入
         */
        public DailyReimbursesController(DailyReimburseService service)
        {
            _service = service;
        }

        /// <summary>
        /// 获取列表
        /// </summary>
        [HttpGet]
        [ProducesResponseType(typeof(DailyReimburseView), 200)]
        public async Task<IActionResult> GetDailyReimburseList([FromQuery] DailyReimburseSearchDTO model)
        {
            var response = await _service.GetDailyReimburseList(model);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 新增
        /// </summary>
        [HttpPost]
        public async Task<IActionResult> AddDailyReimburse([FromBody] DailyReimburseAddDTO model)
        {
            var response = await _service.AddDailyReimburse(model);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 修改
        /// </summary>
        [HttpPut]
        public async Task<IActionResult> PutDailyReimburse([FromBody] DailyReimburseUpdateDTO model)
        {
            var response = await _service.PutDailyReimburse(model);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 删除
        /// </summary>
        [HttpDelete]
        public async Task<IActionResult> DeleteDailyReimburse([FromQuery] string Id)
        {
            var response = await _service.DeleteDailyReimburse(Id);
            return StatusCode(response.Status, response);
        }

    }
}
